Skip to content

formatting - #5

Merged
okotek merged 1 commit into
mainfrom
enhancment/markdown
Jul 6, 2023
Merged

okotek merged 1 commit into
mainfrom
enhancment/markdown

Conversation

@mrT23

@mrT23 mrT23 commented Jul 6, 2023 •

Copy link
Copy Markdown
Contributor

User description

add nicer formatting


PR Type

Enhancement, Documentation


Description

  • Enhanced markdown formatting in utils.py for better code suggestion display.
  • Improved question handling and added logging in pr_questions.py.
  • Refactored PR review preparation and updated usage instructions in pr_reviewer.py.
  • Updated prompts in pr_questions_prompts.toml and pr_reviewer_prompts.toml for clarity and relevance.

Changes walkthrough 📝

Relevant files
Enhancement
utils.py
Enhance markdown formatting for code suggestions                 

pr_agent/algo/utils.py

  • Improved markdown formatting for code suggestions.
  • Removed redundant suggestion number formatting.
  • Added handling for relevant file information.
  • +6/-2     
    pr_questions.py
    Improve question handling and add logging                               

    pr_agent/tools/pr_questions.py

  • Corrected typo in question string.
  • Added logging for answer string when verbosity is high.
  • +3/-1     
    pr_reviewer.py
    Refactor PR review preparation and update instructions     

    pr_agent/tools/pr_reviewer.py

  • Reordered data for better display.
  • Updated markdown instructions for usage.
  • +11/-2   
    Documentation
    pr_questions_prompts.toml
    Update PR questions prompt for relevance                                 

    pr_agent/settings/pr_questions_prompts.toml

    • Added instruction to answer only relevant questions.
    +1/-0     
    pr_reviewer_prompts.toml
    Clarify PR reviewer prompt descriptions                                   

    pr_agent/settings/pr_reviewer_prompts.toml

    • Clarified description for minimal and focused PR question.
    +2/-2     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    @mrT23
    mrT23 requested a review from okotek July 6, 2023 09:49
    @okotek
    okotek merged commit 74dfae8 into main Jul 6, 2023
    @okotek
    okotek deleted the enhancment/markdown branch July 6, 2023 10:00
    yochail pushed a commit to yochail/pr-agent that referenced this pull request Feb 11, 2024
    @mrT23 mrT23 added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 14, 2024
    @mrT23

    mrT23 commented Oct 14, 2024

    Copy link
    Copy Markdown
    Contributor Author

    PR Description updated to latest commit (e53ae71)

    mrT23 pushed a commit that referenced this pull request May 25, 2025
    feat: conditionally append Mermaid sequence diagram instruction in prompt
    agonzalesipcoop-cmyk pushed a commit to agonzalesipcoop-cmyk/pr-agent that referenced this pull request May 8, 2026
    …view
    
    - Extract loader into pr_agent/algo/best_practices.py and reuse it from
      /improve and /review so OSS behavior is symmetric (closes Qodo The-PR-Agent#1).
    - Guard int(max_lines_allowed) with TypeError/ValueError fallback to 800
      plus a targeted warning (Qodo The-PR-Agent#2).
    - Bitbucket get_pr_agent_repo_custom_file: only accept HTTP 200, log
      non-404 failures, add 10s timeout, and use the repo default branch
      via get_repo_default_branch (Qodo The-PR-Agent#3, The-PR-Agent#5, The-PR-Agent#6).
    - LocalGitProvider get_pr_agent_repo_custom_file: resolve and verify the
      candidate path stays inside the repo root before reading (Qodo The-PR-Agent#7).
    - Soften prompt wording in code-suggestions templates and add a parallel
      block in pr_reviewer_prompts.toml so the model treats the section as
      guidance, ignoring obvious non-guideline content.
    - Drop unused _FakeContext test helper, retarget patches to the new
      module, add coverage for the invalid max_lines fallback (Qodo The-PR-Agent#4).
    - Update docs/improve.md and docs/review.md to reflect that both tools
      now consume best_practices.md in OSS.
    
    Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
    @dellch dellch mentioned this pull request Jun 2, 2026
    3 tasks done
    Oxygen56 added a commit to Oxygen56/pr-agent that referenced this pull request Jun 8, 2026
    - Use compiled Asana patterns (_ASANA_TASK_URL_PATTERN,
      _ASANA_TASK_SHORT_PATTERN) in find_asana_tickets() instead of
      inline regex (CodeQL unused-variable, comments The-PR-Agent#5/The-PR-Agent#6).
    - Add re.IGNORECASE flag to _ASANA_TASK_SHORT_PATTERN for proper
      case-insensitive matching.
    - Replace substring match ('app.asana.com' in ticket) with
      prefix check (ticket.startswith()) to fix CodeQL URL
      sanitization warning (comment The-PR-Agent#4).
    - Reserve at least one slot for Asana tickets during
      truncation when there are 3+ GitHub/branch tickets
      (comment The-PR-Agent#8).
    - Dedent only actual leading whitespace instead of blindly
      slicing dline[remove_count:] to avoid deleting real code
      on lines with less indentation (comments The-PR-Agent#3/The-PR-Agent#9).
    - Remove unused 'import pytest' from test file
      (comments The-PR-Agent#10/The-PR-Agent#20).
    - Add test_shorthand_mixed_case_asana and
      test_shorthand_respects_word_boundary test cases.
    Oxygen56 added a commit to Oxygen56/pr-agent that referenced this pull request Jun 8, 2026
    - Use compiled Asana patterns (_ASANA_TASK_URL_PATTERN,
      _ASANA_TASK_SHORT_PATTERN) in find_asana_tickets() instead of
      inline regex (CodeQL unused-variable, comments The-PR-Agent#5/The-PR-Agent#6).
    - Add re.IGNORECASE flag to _ASANA_TASK_SHORT_PATTERN for proper
      case-insensitive matching.
    - Replace substring match ('app.asana.com' in ticket) with
      prefix check (ticket.startswith()) to fix CodeQL URL
      sanitization warning (comment The-PR-Agent#4).
    - Reserve at least one slot for Asana tickets during
      truncation when there are 3+ GitHub/branch tickets
      (comment The-PR-Agent#8).
    - Dedent only actual leading whitespace instead of blindly
      slicing dline[remove_count:] to avoid deleting real code
      on lines with less indentation (comments The-PR-Agent#3/The-PR-Agent#9).
    - Remove unused 'import pytest' from test file
      (comments The-PR-Agent#10/The-PR-Agent#20).
    - Add test_shorthand_mixed_case_asana and
      test_shorthand_respects_word_boundary test cases.
    ashearin added a commit to ashearin/pr-agent that referenced this pull request Jun 29, 2026
    …h failures via typed exception
    
    Addresses Qodo review items The-PR-Agent#2, The-PR-Agent#3, The-PR-Agent#4 on PR The-PR-Agent#2483.
    
    The-PR-Agent#2 Hardcoded managed_default label set
    - Add is_describe_managed_label() and _describe_managed_label_names() in
      pr_agent.algo.utils as the single source of truth for the
      /describe-managed namespace.
    - Rewrite get_user_labels() to defer to the same helper so the inclusion
      and exclusion rules can never drift.
    
    The-PR-Agent#3 Default label not managed (Bug fix with tests)
    - When enable_custom_labels=True and no custom_labels are configured,
      set_custom_labels injects defaults that include 'Bug fix with tests'.
      is_describe_managed_label now classifies that label as managed so
      /describe can remove it once it is no longer recommended.
    - This also fixes a pre-existing bug in get_user_labels where
      'Bug fix with tests' was misclassified as a user label.
    
    The-PR-Agent#4 Refresh failure misreported
    - Add LabelRefreshError in pr_agent.git_providers.git_provider so
      callers can distinguish a refresh failure from a genuine no-op.
    - GitProvider.publish_managed_labels (default impl) and
      GitLabProvider.publish_managed_labels now raise LabelRefreshError on
      pre-write refresh failure instead of returning None.
    - PRDescription._safe_publish_labels and PRReviewer.set_review_labels
      catch LabelRefreshError specifically and log a warning that names the
      failure, instead of mis-logging it as 'labels unchanged' /
      'already set'.
    
    #1, The-PR-Agent#5, The-PR-Agent#6, The-PR-Agent#7 from Qodo's review are already addressed in earlier
    commits on this branch (36ec454, a7a8cad); Qodo's review listing is
    pinned to PR-level diff hunks so they appear in the report against
    older revisions.
    
    Tests:
    - New TestDescribeManagedLabelNamespace locks the predicate behavior:
      default-set always managed, Bug fix with tests managed under the
      custom-labels default-injection path, and is_describe_managed_label /
      get_user_labels stay disjoint.
    - TestSafePublishLabels gains test_predicate_includes_bug_fix_with_tests_when_custom_labels_default
      and test_logs_distinctly_on_refresh_failure.
    - test_pr_reviewer_core gains test_set_review_labels_logs_distinctly_on_refresh_failure.
    - test_publish_managed_labels_aborts_when_refresh_fails replaced with
      test_publish_managed_labels_raises_when_refresh_fails.
    - Full unit suite: 1066 passed, 1 skipped, 3 xfailed (was 1060).
    
    Signed-off-by: Allen Shearin <allen.p.shearin@gmail.com>
    naorpeled referenced this pull request in utsab345/pr-agent Jul 3, 2026
    …in restricted mode
    
    Address Qodo review on The-PR-Agent#2491:
    
    - #4 (skip path drops changelog output): when a changelog push is requested but not
      possible — provider lacks push support, or restricted_mode disables push_code — the
      tool no longer returns early with only an error. It now still generates the changelog
      and publishes it as a comment (which only needs pull-requests: write), with a note that
      the changes were not pushed. commit_changelog is set to False in that case.
    - #5 (skip path still initializes): removes the special early-return init path; the normal
      flow builds only what's needed to generate the changelog.
    - #6 (contents default note misleading): clarify that unlisted scopes default to none only
      within an explicit permissions: block; without one, defaults follow repo/org settings.
    
    Update the "no push support" test to assert the comment fallback, and add a restricted_mode
    test (push API present but is_supported('push_code') False) asserting it comments, not pushes.
    naorpeled added a commit that referenced this pull request Jul 3, 2026
    * fix: scope ticket cache per-PR and fix Dynaconf list merge leaks in tests
    
    - Cache key is now 'related_tickets_<md5(pr_url)>' instead of global
      'related_tickets', preventing stale tickets leaking between unrelated PRs
    - Added cache_tickets=true config flag under [pr_reviewer] to allow disabling
    - Fixed Dynaconf merge_enabled=True list append bug in both production code
      (env_bridge.py uses case-insensitive pop before set) and test helpers
      (restore_settings now calls _remove_key before every set)
    - Added azure-identity dependency for Azure DevOps provider availability
    - 1043 tests pass, 0 failures
    
    * Revert "fix: scope ticket cache per-PR and fix Dynaconf list merge leaks in tests"
    
    This reverts commit 7f0d154.
    
    * feat: add restricted mode for reduced GitHub permissions (#2279)
    
    Add a `config.restricted_mode` option that gates operations requiring
    elevated permissions (e.g. pushing code to the repository). When enabled,
    `is_supported("push_code")` returns `False` on GitHub, GitLab, and
    Bitbucket providers, and `/update_changelog --push_changelog_changes=true`
    gracefully skips with a clear message instead of failing.
    
    Users can set `restricted_mode = true` and use only `issues: write`
    and `pull-requests: write` permissions, without `contents: write`.
    
    * docs: document restricted_mode for reduced GitHub permissions
    
    * docs: clarify minimal permissions for restricted mode
    
    * fix: move restricted-mode check to __init__ to avoid unnecessary provider reads
    
    PRUpdateChangelog.__init__() was fetching languages, files, and
    CHANGELOG.md content before run() checked push_code support.
    In restricted mode, these reads were wasted and could fail if
    contents access is also restricted.
    
    Move the capability check into __init__() before the expensive
    provider calls, and store the result in self._skip_push so
    run() can return early.
    
    * fix: remove full-config logging from run() and use mock AI handler in test
    
    - Remove relevant_configs logging that dumps full settings dicts
      (potential secret leak in logs)
    - Pass ai_handler mock in test_run_without_push_support to avoid
      instantiating a real LiteLLMAIHandler
    
    * fix: use spec'd mock for push-support test and fix docs permissions note
    
    - Use MagicMock(spec=[...]) in test_run_without_push_support so
      hasattr() correctly returns False for missing attributes instead
      of brittle delattr on bare MagicMock
    - Remove misleading 'contents: read (defaults to read)' comment
      from restricted mode docs; contents is simply not needed
    
    * fix: skip __init__ provider reads when _skip_push is set
    
    Move all provider-dependent initialization (vars dict, token handler,
    ai_handler binding, language/file/changelog reads) behind the _skip_push
    guard so the skip path avoids hitting the git provider at all during
    construction.
    
    * fix(update_changelog): degrade to comment instead of dropping output in restricted mode
    
    Address Qodo review on #2491:
    
    - #4 (skip path drops changelog output): when a changelog push is requested but not
      possible — provider lacks push support, or restricted_mode disables push_code — the
      tool no longer returns early with only an error. It now still generates the changelog
      and publishes it as a comment (which only needs pull-requests: write), with a note that
      the changes were not pushed. commit_changelog is set to False in that case.
    - #5 (skip path still initializes): removes the special early-return init path; the normal
      flow builds only what's needed to generate the changelog.
    - #6 (contents default note misleading): clarify that unlisted scopes default to none only
      within an explicit permissions: block; without one, defaults follow repo/org settings.
    
    Update the "no push support" test to assert the comment fallback, and add a restricted_mode
    test (push API present but is_supported('push_code') False) asserting it comments, not pushes.
    
    * fix: generate changelog preview instead of silent skip when push is restricted
    
    When restricted_mode is active and push_changelog_changes=true, the
    tool now generates the changelog output via AI and publishes it as a
    comment with a '(push restricted by configuration)' label, instead of
    returning silently. This ensures users see the changelog even when
    they don't have contents: write permissions.
    
    For the 'not supported' case (provider lacks create_or_update_pr_file
    entirely), the existing early-return behavior is preserved.
    
    ---------
    
    Co-authored-by: Utsab <utsab@pr-agent.dev>
    Co-authored-by: naorpeled <me@naor.dev>
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    documentation Improvements or additions to documentation enhancement New feature or request

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants